﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZG_member.BLL;
using System.Security.Cryptography;
using System.Configuration;


namespace ZG_member
{
    public partial class specialrebate : Form
    {
        public specialrebate()
        {
            InitializeComponent();
            skinEngine1.SkinFile = Application.StartupPath + ConfigurationManager.AppSettings["Skin"];
            this.Opacity = 0;
        }
        public int aa = 0;
        private void button1_Click(object sender, EventArgs e)
        {
            Model.operatorInfo o = new Model.operatorInfo();
            operatorInfo ot = new operatorInfo();
            string passWord = this.textBox2.Text;
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] bt = Encoding.Default.GetBytes(passWord);
            bt = md5.ComputeHash(bt);
            passWord = BitConverter.ToString(bt).Replace("-", "");

            try
            {
                o = ot.GetModelList(" username = '" + this.textBox1.Text + "' and password = '" + passWord + "'")[0];
            }
            catch (Exception)
            {

                MessageBox.Show("折扣启用失败！");
                return;
            }
  
            Model.roleInfo r = new Model.roleInfo();
            roleInfo ri = new roleInfo();
            r = ri.GetModel((int)o.roleId);
            
            if (r.Specialrebate == "1")
            {
                aa = 1;
                this.Close();
            }else
	        {
                MessageBox.Show("折扣启用失败！");
                this.Close();
                aa = 2;
	        }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            aa = 3;
            this.Close();
            return;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //timer开启
            this.Left += 2;
            this.Opacity += 0.1;
            if (Opacity == 1)
            {
                this.timer1.Stop();

            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            //timer关闭
            this.Top = this.Top + 10;
            this.Opacity = this.Opacity - 0.06;
            if (Opacity <= 0)
            {
                this.timer2.Stop();
                this.Close();
            }
        }
        int flag = 0;

        private void specialrebate_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (flag == 0)
            {
                e.Cancel = true;
                flag = 1;
                this.timer2.Start();
            }
        }

        private void specialrebate_Load(object sender, EventArgs e)
        {
            this.timer1.Start();
        }
    }
}
